package com.mikao.dao;

import com.mikao.entity.BuyCar;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * @author kenny
 */
public interface BuyCarDao extends JpaRepository<BuyCar, Long>, JpaSpecificationExecutor {

    /**
     * 根据商品ID和用户ID查找购物车记录
     *
     * @param goodsId 商品ID
     * @param userId  用户ID
     * @return car
     */
    BuyCar findAllByGoodsIdAndUserId(Long goodsId, Long userId);

    /**
     * 根据用户ID查找所有购物车商品
     *
     * @param userId 用户ID
     * @return list
     */
    List<BuyCar> findAllByUserIdOrderByCreateTimeDesc(Long userId);
}
